package com.aierjun.idcardorclib;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

//import com.tianruiworkroomocr.Native;

/**
 * Created by Ani_aierJun on 2017/9/27.
 */

public class TestSampleActivity extends Activity {
    private ImageView one, two;
    public static Bitmap bitmap1, bitmap2, b;
    private Button btn;
    private TextView textView;
    public static String s;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_test);
        findView();
        initView();
    }

    private void findView() {
        btn = (Button) findViewById(R.id.btn);
        one = (ImageView) findViewById(R.id.one);
        two = (ImageView) findViewById(R.id.two);
        textView = (TextView) findViewById(R.id.three);
    }

    private void initView() {
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivityForResult(new Intent(TestSampleActivity.this, CameraActivity.class), 123);
            }
        });

    }


    @Override
    protected void onRestart() {
        initView();
        super.onRestart();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == 123 && requestCode ==123){
            if (data == null) return;
            CameraParcelable cameraParcelable = data.getParcelableExtra("CameraParcelable");
            if (cameraParcelable == null) return;
            textView.setText(cameraParcelable.getId() + "\n" + cameraParcelable.getName() + "\n"
                    + cameraParcelable.getSex() + "\n" + cameraParcelable.getFamilyName() + "\n"
                    + cameraParcelable.getBirthday() + "\n" + cameraParcelable.getIdNumber() + "\n"
                    + cameraParcelable.getAddress());
        }
        super.onActivityResult(requestCode, resultCode, data);
    }
}
